<template>
  <div>
    <!-- 筛选列表 -->
    <el-card style="margin-bottom: 20px" id="search">
      <div slot="header" class="header flex">
        <span>筛选列表</span>
        <div class="header_answer">
          <!-- <el-progress
            :text-inside="true"
            :stroke-width="26"
            :percentage="70"
          ></el-progress> -->
        </div>
      </div>
      <div class="text item">
        <el-form
          :model="queryParams"
          ref="queryForm"
          :inline="true"
          label-width="90px"
          class="serach_contant"
        >
          <el-form-item label="搜索：">
            <el-input
              v-model="queryParams.searchKey"
              placeholder="考点，机房，姓名，科目"
              clearable
              size="small"
              @keyup.enter.native="handleQuery"
            />
          </el-form-item>
          <el-form-item label="所属省份：">
            <el-select
              v-model="queryParams.provinceIds"
              placeholder="搜索省份"
              clearable
              multiple
              size="small"
              @focus="getProvinceName"
              @keyup.enter.native="handleQuery"
            >
              <el-option
                v-for="(item, index) in selectProvince"
                :key="index"
                :label="item.name"
                :value="item.id"
              />
            </el-select>
          </el-form-item>
          <el-form-item>
            <el-button
              type="primary"
              icon="el-icon-search"
              size="mini"
              @click="handleQuery"
              >查询</el-button
            >
            <!-- <el-button icon="el-icon-refresh" size="mini" @click="resetQuery"
              >重置</el-button
            > -->
          </el-form-item>
        </el-form>
      </div>
    </el-card>

    <!-- 标签列表 -->
    <el-card>
      <div class="text item">
        <!--  Table-->
        <el-table v-loading="loading" :data="listExamIng">
          <el-table-column
            type="index"
            width="50"
            align="center"
            label="编号"
          />
          <el-table-column label="省份" align="center" prop="provinceName" />
          <el-table-column
            label="考点"
            align="center"
            prop="examName"
            :show-overflow-tooltip="true"
          />
          <el-table-column
            label="机房"
            align="center"
            prop="examRoomName"
            :show-overflow-tooltip="true"
          />
          <el-table-column label="姓名" align="center" prop="name" />
          <el-table-column label="机号" align="center" prop="pcNo" />
          <el-table-column label="答案" align="center" prop="answerDbMessage" />
          <el-table-column label="科目" align="center" prop="subjectName" />
          <el-table-column label="考试结束时间" align="center" prop="endTime">
            <template slot-scope="scope">
              <span>{{ parseTime(scope.row.endTime, "{h}:{i}:{s}") }}</span>
            </template>
          </el-table-column>
          <el-table-column
            label="状态"
            align="center"
            :formatter="anStatusFormat"
          />
        </el-table>
      </div>
      <!-- page -->
      <pagination
        v-show="total > 0"
        :total="total"
        :page.sync="queryParams.pageNum"
        :limit.sync="queryParams.pageSize"
        @pagination="getList"
      />
    </el-card>
  </div>
</template>
<script>
import Cookies from "js-cookie";
import { listExamIng, getProvince } from "@/api/toolsystem/answers";

export default {
  name: "testOver",
  props: {
    anStatusList: Array, // 算分答案状态列表
  },
  data() {
    return {
      // 遮罩层
      loading: false,
      // 非多个禁用
      multiple: true,
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 表格数据
      list: [],
      // 是否显示弹出层
      open: false,
      // 筛选省
      selectProvince: [],
      // 表单参数
      form: {},
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        provinceIds: [],
        searchKey: null,
      },
      //显示批量管理
      allManage: false,
      btnText: "批量管理",
      // 参考资质列表
      listExamIng: [],
      // 下载入库返回的进度
      msg: "",
    };
  },
  created() {
    this.getList();
  },
  watch: {
    "queryParams.pageNum"(val) {
      // console.log(val)
      Cookies.set("tool_pageNum", val);
    },
    "queryParams.pageSize"(val) {
      // console.log(val)
      Cookies.set("tool_pageSize", val);
    },
  },
  methods: {
    // 算分状态字典翻译
    anStatusFormat(row, column) {
      return this.selectDictLabel(this.anStatusList, row.answerSource);
    },
    // 获取筛选的省份和城市
    getProvinceName() {
      getProvince().then((res) => {
        this.selectProvince = res;
      });
    },

    /** 查询按钮操作 */
    handleQuery() {
      this.queryParams.pageNum = 1;
      // console.log(this.queryParams, "11");
      this.getList();
    },
    // 获取答案list
    getList() {
      this.loading = true;
      // 获取列表
      const pageNum = Cookies.get("tool_pageNum");
      const pageSize = Cookies.get("tool_pageSize");
      // console.log(pageSize, pageNum);
      if (pageNum) {
        this.queryParams.pageNum = Number(pageNum);
      }
      if (pageSize) {
        this.queryParams.pageSize = Number(pageSize);
      }
      let obj = {
        pageNum: this.queryParams.pageNum,
        pageSize: this.queryParams.pageSize,
        searchKey: this.queryParams.searchKey,
      };
      console.log(this.queryParams.provinceIds)
      listExamIng(obj, this.queryParams.provinceIds)
        .then((response) => {
          // console.log(response, "joinlist");
          if (response.code != 200) {
            this.loading = false;
            return;
          }
          this.listExamIng = response.rows;
          // console.log(this.teststieList)
          this.total = response.total;
          // this.$emit("closeApplyJoin", this.total);
          // console.log(this.total)
          this.loading = false;
        })
        .catch((error) => {
          this.loading = false;
          // console.log(error);
        });
    },

    //批量管理
    allMange() {
      this.allManage = !this.allManage;
      if (this.allManage == true) {
        this.btnText = "完成管理";
      } else if (this.allManage == false) {
        this.btnText = "批量管理";
      }
    },
  },
};
</script>
<style lang="scss">
/*@import "@/assets/styles/card.scss";*/
// bannerlist图标的大小
.flex {
  display: flex;
}
.header {
  justify-content: space-between;
}
::-webkit-scrollbar {
  display: none;
}

// 查看MQ
.checkMQ {
  table {
    border-collapse: collapse;
    border-top: 1px solid #000;
    border-left: 1px solid #000;
    .thead {
      display: flex;
      tr {
        flex: 1;
        display: flex;
        td {
          flex: 1;
          text-align: center;
          border-right: 1px solid #000;
          border-bottom: 1px solid #000;
        }
      }
    }
    .tbody {
      tr {
        display: flex;

        td {
          // width: 71px;
          flex: 1;
          text-align: center;
          border-right: 1px solid #000;
          border-bottom: 1px solid #000;
        }
      }
    }
  }
}
// 查看日志
.Journal {
  // position: relative;
  .el-dialog__body {
    padding: 10px 25px 25px;
  }
  .btn_journal {
    // position: absolute;
    // right: 27px;
    justify-content: flex-end;
  }
}
.aa {
  font-size: 20px;
}
.line {
  border-bottom: 1px solid #c0c4cc;
  padding: 20px 0;
}

// search
#search .serach_contant {
  margin-top: 20px;
}
//批量管理
.allManage {
  justify-content: space-between;

  .btnManage {
    justify-content: flex-end;
  }
}
</style>
